<?php
/**
 * Created by PhpStorm.
 * User: EZ
 * Date: 2017/5/26
 * Time: 9:47
 */
namespace core;
class Loader{

    public static $loader=null;
    public static function autoload($class){
        $path_arr=[
           ZDW_PATH,ROOT_PATH
        ];

        foreach($path_arr as $v){
            if(is_file($v.$class.'.php')){
                if(!isset(self::$loader[$class])){
                    require  $v.$class.'.php';
                    self::$loader[$class]=$v.$class.'.php';
                }
            }else{
                if($v==ROOT_PATH && strpos($class,'app')){
                    die("访问了一个不存在的控制器:".$v.'----'.$class);
                }
            }
        }
    }

    public static function register(){
        spl_autoload_register("\\core\\Loader::autoload",true,true);
    }


}